*! version 1.0.0  21apr2020
program define mcre_p, sort
    version 15
 
    syntax newvarname [if] [in] , [ xb pr]
 
    marksample touse, novarlist
 
    local nopts : word count `xb' `pr'
    if `nopts' >1 {
        display "{err}only one statistic may be specified"
        exit 498
    }
 
    if `nopts' == 0 {
        local pr pr
        display "Pr(y=1)"
    }
 
    if "`xb'" != "" {
        _predict `typlist' `varlist' if `touse' , xb
    }
    else {
        tempvar xbv
		tempname a alpha
        quietly _predict double `xbv' if `touse' , xb
		mat `a' = get(_b)
		if `:colnfreeparms e(b)' {
			mat `a' = `a'[1,"/lnalpha"]
		}
		else {
			mat `a' = `a'[1,"ln_a2:_cons"]
		}
		scalar `alpha' = `a'[1,1]
		scalar `alpha' = exp(`alpha')
        generate `typlist' `varlist' = 1 - (1/(1+exp(`xbv'))^`alpha') if `touse'
    }
end